import React from 'react'
import {connect} from 'react-redux'
import {addActionCreator,subActionCreator} from '../store/actions/counterAction'
function Left(props) {
  console.log('props',props);
  return (
    <div style={{flex:1,height:'100vh',background:'springgreen'}}>
       <div>来自App的数据:{props.name}</div>
       <div>来自store中的state:<h1>{props.count}</h1></div>
       <div>
          <button onClick={()=>{
            props.dispatch(addActionCreator(1))
          }}>+1</button>
          <button onClick={()=>{
             props.dispatch(addActionCreator(5))
          }}>+5</button>

          <button onClick={()=>{
            props.dispatch(subActionCreator(3))
          }}>-3</button>
       </div>
    </div>
  )
}
const mapStateToProps=(state)=>{
  return{
    count:state.count
  }
}
export default connect(mapStateToProps)(Left)
